/*
 * 获取数组最大值
 * @param array arr 数组
 */
export const arr_max = (arr) => {
  return Math.max.apply(Math, arr);
}

/*
 * 获取数组最小值
 * @param array arr 数组
 */
export const arr_min = (arr) => {
  return Math.min.apply(Math, arr);
}

/*
 * 输入数组，会随机抽取数组中的一个值输出
 */
export const arr_random = (arr) => {
  return arr[Math.floor(Math.random() * arr.length)];
}

/* 数组求差集 */
export const uplist = (data1,data2) => {
  let set1 = new Set(data1)
  let set2 = new Set(data2)
  return set1.concat(set2).filter(v=> !set1.includes(v) || !set2.includes(v));
}

/* 以某一个数组为标准，求差集 */
export const uplistOne = (data1,data2,filColume) => {
  if(!filColume){
    let set1 = new Set(data1)
    let set2 = new Set(data2)
    return set1.concat(set2.filter(v=>!set1.includes(v)));
  }
  let set1 = new Set(data1)
  let set2 = new Set(data2)
  return set1.concat(set2.filter(v=>set1[filColume] != v[filColume]));
}

